#ifndef SCENENODE_H
#define SCENENODE_H

#include "d3dUtil.h"

class SceneNode
{
public:
	SceneNode(void);
	virtual ~SceneNode(void);

	//find a node from current node,return NULL if the node isn't exist
	SceneNode*			FindNodeByName(const std::string& name);

	//find a node from current node by it's name's substring,return NULL if the node isn't exist
	SceneNode*			FindNodeBySubName(const std::string& name);

	//delete a child node by it's name,
	//if success return the pointer to the deleted node
	//else return NULL
	SceneNode*			DeleteChildByName(const std::string& name);

	//delete a child node by it's name's substring,
	//if success return the pointer to the deleted node
	//else return NULL
	SceneNode*			DeleteChildBySubName(const std::string& name);

	//move a node relatively it's parent
	void				TranslationFromParent(const D3DXVECTOR3& translateVec);

	//Identity node's matrix from parent
	void				MatrixFromParentIdentity();

	bool				HasChildren();
	bool				HasMesh();
	
	//set the node's parent
	void				SetParentSceneNode(SceneNode* parent);

	//get the number of children
	int					GetNumChildren();

	//add a children to this node
	void				AddChildren(SceneNode* node);

	//get the node's world matrix
	D3DXMATRIX			GetWorldMatrix();

	//return the node's name
	std::string			GetNodeName();
	void				SetNodeName(const std::string& name);

	//clone one node and it's children's all attribute,return the root node
	virtual SceneNode*	Clone();

private:
	std::string				m_strSceneNodeName;

	int						m_iNumChildren;
	int						m_iNumMeshs;
	
	SceneNode*				m_pParent;

	D3DXMATRIX				m_matTransFromParent;
	D3DXMATRIX				m_matWorldTransform;

	std::list<int>			m_lstMeshs;
	std::list<SceneNode*>	m_lstChildren;

	friend class ResourcesManager;
	friend class SceneManager;
	friend class Chess;
};

#endif
